﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using HYCreateDuct.FormDuct;
using HYCreateDuct.MethodHelp;

namespace HYCreateDuct
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	internal class cmdCreateDuctSet : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIApplication application = commandData.Application;
			DuctHisHelp ductHisHelp = new DuctHisHelp();
			DuctHis history = ductHisHelp.GetHistory();
			FormDuctSet formDuctSet = new FormDuctSet(application, history.nInner, history.nTypeSelect, ductHisHelp);
			DialogResult dialogResult = formDuctSet.ShowDialog();
			if (dialogResult == DialogResult.OK || dialogResult == DialogResult.Cancel)
			{
				int nInner = formDuctSet.nInner;
				int nTypeSelect = formDuctSet.nTypeSelect;
				ductHisHelp.WriteHistory(nInner, nTypeSelect);
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
